<template>
  <div>
    <van-action-sheet v-model="val" class="kkk">
      <TimePicker
        v-model="deliveryTime"
        @select-time="showDelivery = false"
        @input="value"
        v-if="show"
      ></TimePicker>
    </van-action-sheet>
    <div class="head">
      <img @click="gocar" src="@/assets/image/order/矩形 3.png" alt="" />
      <p>确认订单</p>
      <span></span>
    </div>
    <!-- 地址 -->
    <div
      class="adree"
      @click="adree"
      v-for="(item, index) in getlist"
      :key="index"
    >
      <div v-if="getlist.length > 0" class="add">
        <p class="dizhi">{{ item.addressDetail }}</p>
        <img src="@/assets/image/order/矩形 3 拷贝.png" alt="" />
      </div>
      <div v-if="getlist.length == 0" class="add">
        <p class="dizhi">杭州</p>
        <img src="@/assets/image/order/矩形 3 拷贝.png" alt="" />
      </div>

      <div v-if="getlist.length > 0" class="phone">
        {{ item.name }}{{ item.tel }}
      </div>
      <div v-if="getlist.length == 0" class="phone">周杰伦 555555</div>

      <div class="tip">
        <span>温馨提示</span>
        <p>所选配送地址距离您 1km 以上，请仔细核对</p>
      </div>
    </div>
    <div class="adree" @click="adree" v-if="getlist.length == 0">
      <div class="add">
        <p class="dizhi">杭州</p>
        <img src="@/assets/image/order/矩形 3 拷贝.png" alt="" />
      </div>
      <div class="phone">周杰伦 555555</div>

      <div class="tip">
        <span>温馨提示</span>
        <p>所选配送地址距离您 1km 以上，请仔细核对</p>
      </div>
    </div>
    <!-- 选择送达时间 -->
    <main>
      <div class="time">
        <p class="songda">选择送达时间</p>
        <div class="gg">
          <p @click="time" class="songda">{{ gettime }}</p>
          <img src="@/assets/image/order/矩形 3 拷贝.png" alt="" />
        </div>
      </div>
      <div class="num">
        <div class="img">
          <img :src="i.url" alt="" v-for="i in list" />
        </div>
        <div class="rrr">
          <p class="sl">共{{ list.length }}件</p>
          <img src="@/assets/image/order/矩形 3 拷贝.png" alt="" />
        </div>
      </div>
      <!-- 备注 -->
      <div class="beizhu">
        <p>备注</p>

        <div class="rrrr">
          <span>可以告诉我们您的特殊需求</span>
          <img src="@/assets/image/order/矩形 3 拷贝.png" alt="" />
        </div>
      </div>
      <!-- 商品金额 -->
      <div class="beizhu">
        <p>商品金额</p>

        <div class="rrrr">
          <span class="black">{{ price }}</span>
        </div>
      </div>
      <!-- 配送费 -->
      <div class="beizhu">
        <p>配送费</p>

        <div class="rrrr">
          <span class="black">¥ 0</span>
        </div>
      </div>
      <!-- 优惠券 -->
      <div class="beizhu" @click="yhq">
        <p>优惠券</p>

        <div class="rrrr">
          <span class="black">共 1 张，0 张可用</span>
        </div>
      </div>
      <!-- 共计 -->
      <div class="beizhu">
        <p>共计</p>

        <div class="rrrr">
          <span class="red">{{ price }}</span>
        </div>
      </div>
    </main>
    <Zfb1></Zfb1>
    <Footer :price="price" />
  </div>
</template>

<script>
import Zfb1 from "./Zfb1.vue";
import Footer from "./Footer.vue";
import Time from "./Time.vue";
import Index from "../Index/Index.vue";
import TimePicker from "./TimePicker.vue";

export default {
  data() {
    return {
      val: false,
      gettime: "选择送达时间",
      deliveryTime: "",
      show: 1,
      getlist: [],
      price: 0,
      list: [],
    };
  },
  created() {
    this.getadd();
    this.price = parseFloat(this.$route.query.price).toFixed(2);
    this.list = JSON.parse(localStorage.getItem("list")) || [
      ...this.$route.query.list,
    ];
  },
  methods: {
    onClickLeft() {
      Toast("返回");
    },
    time() {
      this.val = true;
    },
    value(val) {
      this.gettime = val;
    },
    adree() {
      this.$router.push("/address");
    },
    yhq() {
      this.$router.push("/coupon");
    },
    gocar() {
      this.$router.go(-1);
    },
    getadd() {
      this.getlist = this.addrelist.filter((item) => {
        return localStorage.getItem("areaCode") == item.areaCode;
      });
    },
    setcode() {
      localStorage.setItem("areaCode", "330102");
    },
  },
  components: { Zfb1, Footer, Time, Index, TimePicker },

  computed: {
    addrelist() {
      return this.$store.state.addresslist;
    },
  },

  mounted() {},
  // beforeDestroy() {
  //   localStorage.removeItem("list");
  // },
};
</script>

<style lang="less" scoped>
@font-face {
  font-family: "myFont";
  src: url("../../assets/font/苹方黑体简.ttf"); //你的资源目录
  font-weight: normal;
  font-style: normal;
}
* {
  font-family: myFont;
}
.head {
  background-color: #ffcc00 !important;
  height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  border-radius: 10px;

  img {
    display: block;
    margin-left: 40px;
    height: 44px;
    width: 26px;
  }
  p {
    font-size: 40px;
    margin-right: 60px;
    font-weight: 500;
    color: #323232;
  }
}
.adree {
  height: 176px;
  width: 750px;
  background-color: #efefef;
  margin: 0 auto;
  .add {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .dizhi {
      margin-top: 10px;
      margin-left: 20px;
      font-size: 30px;
      line-height: 30px;
    }
    img {
      display: block;
      height: 22px;
      width: 14px;
      margin-top: 14px;
      margin-right: 14px;
    }
  }
  .phone {
    font-size: 24px;
    margin-top: 24px;
  }
  .tip {
    width: 600px;
    height: 40px;
    background: #ffffff;
    border-radius: 20px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    span {
      display: block;
      color: red;
      margin-left: 8px;
      font-size: 22px;
    }
    p {
      margin-left: 10px;
      font-size: 22px;

      font-weight: 400;
      color: #d1d1d1;
    }
  }
}
main {
  padding-left: 18px;
  padding-right: 22px;
  width: 750px;

  background: #efefef;
  border-radius: 10px;
  margin: 0 auto;
  margin-top: 38px;
  .time {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .gg {
      display: flex;
      align-items: center;
      margin-top: 20px;
      margin-bottom: 20px;
    }
    .songda {
      font-size: 30px;
      margin-top: 14px;
      margin-bottom: 14px;
      font-weight: 400;
      color: #646464;
    }
    img {
      display: block;
      width: 14px;
      height: 28px;
      margin-left: 10px;
    }
  }
  .num {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .img {
      display: flex;

      img {
        display: block;
        width: 86px;
        height: 86px;
      }
    }
    .rrr {
      display: flex;
      align-items: center;
      .sl {
        font-size: 30px;
      }
      img {
        display: block;
        width: 14px;
        height: 22px;
        margin-left: 10px;
      }
    }
  }
  .beizhu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    p {
      font-size: 26px;
      display: flex;
      align-items: center;
      margin-top: 14px;
      margin-bottom: 14px;
    }
    .rrrr {
      display: flex;
      align-items: center;
      margin-top: 14px;
      margin-bottom: 14px;

      span {
        display: block;
        font-size: 26px;
        color: #d1d1d1;
      }
      img {
        display: block;
        width: 14px;
        height: 22px;
        margin-left: 10px;
      }
    }
  }
}
.red {
  color: #ff5b5b !important;
}
.black {
  color: #494949 !important;
}
.van-popup {
  font-size: 40px !important;
}
</style>
